1 // Fig. 3.27: fig03_27.cpp 2 // Using a function template 3 #include 4 5 template < class T > 6 T maximum( T value1, T value2, T value3 ) 7 { 8 T max = value1; 9 10 if ( value2 > max ) 11 max = value2; 12 13 if ( value3 > max ) 14 max = value3; 15 16 return max; 17 } 18 19 int main() 20 { 21 int int1, int2, int3; 22 23 cout << "Input three integer values: "; 24 cin >> int1 >> int2 >> int3; 25 cout << "The maximum integer value is: " 26 << maximum( int1, int2, int3 ); // int version 27 28 double double1, double2, double3; 29 30 cout << "\nInput three double values: "; 31 cin >> double1 >> double2 >> double3; 32 cout << "The maximum double value is: " 33 << maximum( double1, double2, double3 ); // double version 34 35 char char1, char2, char3; 36 37 cout << "\nInput three characters: "; 38 cin >> char1 >> char2 >> char3; 39 cout << "The maximum character value is: " 40 << maximum( char1, char2, char3 ) // char version 41 << endl; 42 43 return 0; 44 }